<?php

if($bean = UserManager::GetUser(App::$Current->Page->User))
{
	?>
	<h1><?php text('Profile of') ?> <?php print $bean->fullname ?></h1>
	<br />
	<a href="/user/by/<?php print $bean->login ?>"><?php text('Ratings by') ?> <?php print App::$Current->Page->User == App::$Current->User ? text('You') : $bean->fullname ?></a><br />
	<br />
	<a href="/user/to/<?php print $bean->login ?>"><?php text('Ratings to') ?> <?php print App::$Current->Page->User == App::$Current->User ? text('you') : $bean->fullname ?></a><br />
	<br />
	<br />
	<?php 
	if(!is_null(App::$Current->User))
	{
		// current user >> rate >> profile user
		if($rating = RatingManager::GetRating(App::$Current->User, App::$Current->Page->User))
		{
			printRatingDetails($rating);
		}
		else 
		{
			?><a href="/user/rate/<?php print $bean->login ?>"><?php text('Rate') ?> <?php print $bean->fullname ?>.</a><?php 	
		}

		// profile user >> rate >> current user
		if(App::$Current->Page->User != App::$Current->User 
			&& $rating = RatingManager::GetRating(App::$Current->Page->User, App::$Current->User))
		{
			printRatingDetails($rating);
		}		
	}
	else 
	{
		?><a href="/login"><?php text('Login to rate') ?> <?php print $bean->fullname ?>.</a><?php 	
	}
	
	?><h2><?php text( 'Updates' ) ?></h2><?php 
	$updates = RatingUpdateManager::GetRatingUpdatesForUser(App::$Current->Page->User);
	foreach($updates as $update)
	{
		printRatingDetails($update);
	}
}
else
{
	?><h1><?php text('User') ?> <?php print App::$Current->Page->User ?> <?php text('was not found.') ?></h1><?php 
}